#include "topmenuwidget.h"
#include "ui_topmenuwidget.h"
#include <QDebug>
#include <QPalette>

TopMenuWidget::TopMenuWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::TopMenuWidget),
    m_isFullScreen(false)
{
    ui->setupUi(this);
    QPalette pal(this->palette());
    pal.setColor(QPalette::Background, Qt::yellow);
    this->setAutoFillBackground(true);
    this->setPalette(pal);
}

TopMenuWidget::~TopMenuWidget()
{
    delete ui;
}

void TopMenuWidget::enterEvent(QEvent */*event*/)
{
    emit mouseEnter();
}

void TopMenuWidget::leaveEvent(QEvent */*event*/)
{
    emit mouseLeave();
}

void TopMenuWidget::setFullScreen(bool flag)
{
    m_isFullScreen = flag;
    QIcon icon;
    if(m_isFullScreen)
    {
        icon=QIcon(":/icon/toNormal.png");
    }
    else
    {
        icon=QIcon(":/icon/toFullscreen.png");
    }
    this->ui->fullscreenPushButton->setIcon(icon);
}

void TopMenuWidget::on_fullscreenPushButton_clicked()
{
    if(!m_isFullScreen)
    {
        setFullScreen(true);
        emit fullScreen();
    }
    else
    {
        setFullScreen(false);
        emit normalScreen();
    }
}
